home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Include / classobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  2.2 KB  |  69 lines

  1. #ifndef Py_CLASSOBJECT_H
  2. #define Py_CLASSOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /* Class object interface */
  8.  
  9. /* Revealing some structures (not for general use) */
  10.  
  11. typedef struct {
  12.     PyObject_HEAD
  13.     PyObject    *cl_bases;    /* A tuple of class objects */
  14.     PyObject    *cl_dict;    /* A dictionary */
  15.     PyObject    *cl_name;    /* A string */
  16.     /* The following three are functions or NULL */
  17.     PyObject    *cl_getattr;
  18.     PyObject    *cl_setattr;
  19.     PyObject    *cl_delattr;
  20. } PyClassObject;
  21.  
  22. typedef struct {
  23.     PyObject_HEAD
  24.     PyClassObject    *in_class;    /* The class object */
  25.     PyObject    *in_dict;    /* A dictionary */
  26. } PyInstanceObject;
  27.  
  28. typedef struct {
  29.     PyObject_HEAD
  30.     PyObject *im_func;   /* The callable object implementing the method */
  31.     PyObject *im_self;   /* The instance it is bound to, or NULL */
  32.     PyObject *im_class;  /* The class that defined the method */
  33. } PyMethodObject;
  34.  
  35. extern DL_IMPORT(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
  36.  
  37. #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
  38. #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
  39. #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
  40.  
  41. extern DL_IMPORT(PyObject *) PyClass_New Py_PROTO((PyObject *, PyObject *, PyObject *));
  42. extern DL_IMPORT(PyObject *) PyInstance_New Py_PROTO((PyObject *, PyObject *, PyObject *));
  43. extern DL_IMPORT(PyObject *) PyMethod_New Py_PROTO((PyObject *, PyObject *, PyObject *));
  44.  
  45. extern DL_IMPORT(PyObject *) PyMethod_Function Py_PROTO((PyObject *));
  46. extern DL_IMPORT(PyObject *) PyMethod_Self Py_PROTO((PyObject *));
  47. extern DL_IMPORT(PyObject *) PyMethod_Class Py_PROTO((PyObject *));
  48.  
  49. /* Macros for direct access to these values. Type checks are *not*
  50.    done, so use with care. */
  51. #define PyMethod_GET_FUNCTION(meth) \
  52.         (((PyMethodObject *)meth) -> im_func)
  53. #define PyMethod_GET_SELF(meth) \
  54.     (((PyMethodObject *)meth) -> im_self)
  55. #define PyMethod_GET_CLASS(meth) \
  56.     (((PyMethodObject *)meth) -> im_class)
  57.  
  58. extern DL_IMPORT(int) PyClass_IsSubclass Py_PROTO((PyObject *, PyObject *));
  59.  
  60. extern DL_IMPORT(PyObject *) PyInstance_DoBinOp
  61.     Py_PROTO((PyObject *, PyObject *,
  62.           char *, char *,
  63.           PyObject * (*) Py_PROTO((PyObject *, PyObject *)) ));
  64.  
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif /* !Py_CLASSOBJECT_H */
  69.